//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  http://www.nopCommerce.com/License.aspx. 
// 
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
// See the License for the specific language governing rights and limitations under the License.
// 
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
// 
// Contributor(s): _______. 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic.Alesko;
using NopSolutions.NopCommerce.BusinessLogic.Directory;
using NopSolutions.NopCommerce.BusinessLogic.Profile;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;
 
namespace NopSolutions.NopCommerce.Web.Administration.Modules
{
    public partial class HtmlContentInfoControl : BaseNopAdministrationUserControl
    {
        private void BindData()
        {
            NopSolutions.NopCommerce.BusinessLogic.Alesko.HtmlContent HtmlContent = this.HtmlContentService.GetHtmlContentById(this.ContentId);
            if (HtmlContent != null)
            {
                this.txtContentName.Text = HtmlContent.ContentName;
                this.txtContentHtml.Value = HtmlContent.ContentHtml;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.BindData();
            }
        }

        public NopSolutions.NopCommerce.BusinessLogic.Alesko.HtmlContent SaveInfo()
        {
          NopSolutions.NopCommerce.BusinessLogic.Alesko.HtmlContent HtmlContent = this.HtmlContentService.GetHtmlContentById(ContentId);
            if (HtmlContent != null)
            {
                HtmlContent.ContentHtml = txtContentHtml.Value;
                this.HtmlContentService.UpdateHtmlContent(HtmlContent);
            }
            /*else
            {
                HtmlContent = new HtmlContent()
                {
                    LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value),
                    Title = txtTitle.Text,
                    Short = txtShort.Text,
                    Full = txtFull.Value,
                    Published = cbPublished.Checked,
                    AllowComments = cbAllowComments.Checked,
                    CreatedOn = DateTime.UtcNow
                };
                this.HtmlContentService.InsertHtmlContent(HtmlContent);
            }*/
            return HtmlContent;
        }

        public int ContentId
        {
            get
            {
                return CommonHelper.QueryStringInt("ContentId");
            }
        }
    }
}